\documentclass[a4paper]{ctexart}
\usepackage[hidelinks]{hyperref}%目录
\usepackage{listing}
\usepackage{xeCJK} %导入这个宏包，就可以支持中文
\usepackage{cite}%文献引用
\usepackage{graphicx}
\usepackage{amsthm,amsmath,amssymb,amsfonts}%数学命题，数学字母，排版
\usepackage[a4paper,left=25.4mm,right=25.4mm,top=29.8mm,bottom=29.8mm]{geometry}

\pagestyle{myheadings}
\numberwithin{equation}{section}%以section编号equation




%数学命题环境定义 
%证明环境直接用proof
\theoremstyle{plain} \newtheorem{thm}{定理}[section]
\theoremstyle{plain} \newtheorem*{lemma}{引理}
\theoremstyle{plain} \newtheorem*{prop}{prop}
\theoremstyle{plain} \newtheorem*{property}{性质}
\theoremstyle{definition} \newtheorem*{define}{定义}
\theoremstyle{plain} \newtheorem*{cor}{cor}
\theoremstyle{plain} \newtheorem{eg}{例}
\theoremstyle{plain} \newtheorem{axiom}{公理}
\theoremstyle{remark} \newtheorem*{rmk}{Rmk}
\theoremstyle{plain} \newtheorem*{goal}{Goal}



\title{Analysis}
\author{陈宇涛，强数2101,3210102287}


\begin{document}


\section{DoubleLinkedList}
\markright{DoubleLinkedList}
\subsection{设计思路}



\begin{flushleft}
    \quad 使用了书上91页以后的代码来建立doublelinkedlist结构,创建了一个类List,其中包含一个子类iterator,可以实现对于
    链表两端的添加元素,删除元素,插入以及删除元素,以及清空链表和判断链表是否为空等操作。
\end{flushleft}



\subsection{测试说明}


\begin{eg}
\begin{flushleft}
    
1.创建链表L,插入元素0,1,2,3,4,5\\
    \begin{verbatim}
        List<int> L;
        L.push_back(0);
        L.push_back(1);
        L.push_back(2);
        L.push_back(3);
        L.push_back(4);
        L.push_back(5);

        PrintList(L);
    \end{verbatim}

    
2.输出L\\
   \begin{verbatim}
    void PrintList(const List<int> &L)
    {
        List<int>::const_iterator it;
         for(it = L.begin();it!= L.end();it++ )
         {
          cout << *it <<" ";
        }
         cout << endl;
     }
   \end{verbatim}
    
   3.添加函数\\
   \begin{verbatim}
    iterator erase(List<int>::iterator iter, Object val)
    {
        if(*iter == val) erase(iter);
    }
   \end{verbatim}

   4.完成过程\\

   \begin{verbatim}

    iter =  find(L, 2);
    L.erase(iter);
    PrintList(L);

    
    iter = find(L,2);		
    L.erase(iter,2);
    PrintList(L);
   

    chen@chen-VirtualBox:~/Project/数据结构与算法/hwk01$ make
    g++ -c main.cpp -o main.o
    g++ -o test main.o
    chen@chen-VirtualBox:~/Project/数据结构与算法/hwk01$ ./test
    0 1 2 3 4 5 
    0 1 3 4 5 
    0 1 3 4 5 

   \end{verbatim}


   5.测试内存泄漏\\
   \begin{verbatim}
    chen@chen-VirtualBox:~/Project/数据结构与算法/hwk01$  valgrind ./test
    ==16045== HEAP SUMMARY:
    ==16045==     in use at exit: 0 bytes in 0 blocks
    ==16045==   total heap usage: 10 allocs, 10 frees, 73,920 bytes allocated
    ==16045== 
    ==16045== All heap blocks were freed -- no leaks are possible
    ==16045== 
    ==16045== For lists of detected and suppressed errors, rerun with: -s
    ==16045== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
   \end{verbatim}
\end{flushleft}
\end{eg}

\end{document}